package hhm.android.library.weightHeightPicker.weightPicker;

import androidx.annotation.NonNull;

import java.util.ArrayList;

public class MGAdapter extends BaseWeightAdapter {

    public MGAdapter(@NonNull WeightParams dateParams, @NonNull WeightPick datePick, int selectColor) {
        super(dateParams, datePick, selectColor);
    }

    @Override
    public String getItem(int position) {
        int number = mData.get(position);
        if (mDatePick.kg >= 100) {
            return "" + number;
        } else {
            if (number < 10) {
                return "0" + number;
            } else {
                return "" + number;
            }
        }
    }

    @Override
    public int getCurrentIndex() {
        return mData.indexOf(mDatePick.mg);
    }

    @Override
    public void refreshValues() {
        ArrayList<Integer> values = new ArrayList<>();
        if (mDatePick.kg >= 100) {
            for (int i = 0; i < 10; i++) {
                values.add(i);
            }
        } else {
            for (int i = 0; i < 100; i++) {
                values.add(i);
            }
        }
        setData(values);
    }
}

